//
//  TYZBaseView.m
//  TYZKit
//
//  Created by TangBin on 2018/6/8.
//  Copyright © 2018年 TangBin. All rights reserved.
//

#import "TYZBaseView.h"

@interface TYZBaseView ()
@property (nonatomic, assign) CGFloat borderWidth;
@end

@implementation TYZBaseView



- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self initWithVar];
        
        [self initWithSubView];
    }
    return self;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self)
    {
        [self initWithVar];
        
        [self initWithSubView];
    }
    return self;
}

- (void)initWithVar
{
    self.borderWidth = 0.5;
}

- (void)initWithSubView
{
    
}

- (NSMutableArray *)viewList
{
    if (!_viewList) {
        _viewList = [NSMutableArray new];
    }
    return _viewList;
}

- (NSMutableArray *)dataList
{
    if (!_dataList) {
        _dataList = [NSMutableArray new];
    }
    return _dataList;
}

- (void)addViewShadow
{
    [self addViewShadow:YES shadowOffset:CGSizeMake(-3, 3) shadowColor:nil];
}

- (void)addViewShadow:(BOOL)borderLine borderColor:(nullable UIColor *)borderColor
{
    [self addViewShadow:borderLine shadowOffset:CGSizeMake(-3, 3) shadowColor:[UIColor colorWithHexString:@"#aaaaaa"] borderColor:borderColor];
}

- (void)addViewShadow:(BOOL)borderLine borderColor:(nullable UIColor *)borderColor borderWidth:(CGFloat)borderWidth
{
    self.borderWidth = borderWidth;
    [self addViewShadow:borderLine borderColor:borderColor];
}

/**
 Description
 
 @param borderLine 是否有边框
 */
- (void)addViewShadow:(BOOL)borderLine shadowOffset:(CGSize)shadowOffset shadowColor:(UIColor *)shadowColor
{
    [self addViewShadow:borderLine shadowOffset:shadowOffset shadowColor:shadowColor borderColor:[UIColor colorWithHexString:@"#aaaaaa"]];
    
}

- (void)addViewShadow:(BOOL)borderLine shadowOffset:(CGSize)shadowOffset shadowColor:(UIColor *)shadowColor borderColor:(UIColor *)borderColor
{
    if (borderLine)
    {
        self.layer.borderWidth = self.borderWidth;
        self.layer.borderColor = borderColor.CGColor;
    }
    self.layer.cornerRadius = 5;
    if (shadowColor == nil)
    {
        self.layer.shadowColor = [UIColor colorWithHexString:@"#aaaaaa"].CGColor;
    }
    else
    {
        self.layer.shadowColor = shadowColor.CGColor;
    }
    self.layer.shadowOpacity = 0.5;
    self.layer.shadowOffset = shadowOffset;
}

- (void)updateWithViewData:(id)data
{
    
}

+ (CGFloat)viewHeight
{
    return 0;
}

+ (CGFloat)viewWidth
{
    return 0;
}

@end

